# R program to get the gender of a list of names 

# Load required libraries
library(dplyr)
library(genderBR)

# Get command-line arguments
args <- commandArgs(trailingOnly = TRUE)

# Parse arguments
input_path <- args[1]         # e.g., "$files/repids.csv"
output_path <- args[2]       # e.g., "$files/genderBR/repids_gender.csv"

# Read data
Data <- read.csv(input_path)

# Use the first column as first names
Firstname <- Data[[1]]
Data$gender <- get_gender(Firstname)

# Write to output file (output_file should be full path or relative to current)
write.csv(Data, output_path, row.names = FALSE)


